<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2021/4/28 0028
 * Time: 22:05
 */

namespace logicmodel;


use comservice\Response;
use datamodel\Banner;
use datamodel\News;
use datamodel\Notice;

class IndexLogic
{

    /**
     * 轮播图列表
     * @return array
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     * @throws \think\exception\DbException
     */
    public function bannerList(){
       $data =  (new Banner())->where(['is_del'=>0,'is_show'=>1])->select();
        if($data){
            $data = collection($data)->toArray();
            $data = addWebSiteUrl($data,['image']);
            return Response::success('success',$data);
        }
        return Response::success('暂无数据',[]);
    }

    /**
     * 公告列表
     * @return array
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     * @throws \think\exception\DbException
     */
    public function noticeList(){
        $data = (new Notice())->where(['is_del'=>0,'is_show'=>1])->order(['order asc'])->select();
        if($data){
            $data = collection($data)->toArray();
            foreach ($data as &$v){
                $v['content'] = content($v['content']);
            }
            return Response::success('success',$data);
        }
        return Response::success('暂无数据',[]);
    }

}